package com.sn.campus.serviceImpl;

import com.google.gson.Gson;
import com.sn.campus.dao.TBaseTestDao;
import com.sn.campus.dao.TFaceRecognitionRecordDao;
import com.sn.campus.entity.TBaseTest;
import com.sn.campus.entity.TFaceRecognitionRecord;
import com.sn.campus.service.TFaceRecognitionRecordService;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class TFaceRecognitionRecordServiceImpl implements TFaceRecognitionRecordService {

    @Resource
    private TFaceRecognitionRecordDao faceRecognitionRecordDao;

    @Resource
    private TBaseTestDao tBaseTestDao;

    public void addData(JSONObject params) {
        //1、创建Gson对象
        Gson gson = new Gson();
        String json = gson.toJson(params.get("data"));
        System.out.println(json);
        TFaceRecognitionRecord faceRecognitionRecord = gson.fromJson(json, TFaceRecognitionRecord.class);
        String communityNo = tBaseTestDao.selectByName(faceRecognitionRecord.getCommunityname());

        faceRecognitionRecordDao.insert(faceRecognitionRecord);

        faceRecognitionRecordDao.invokeData(communityNo,faceRecognitionRecord.getCommunityname(),
                faceRecognitionRecord.getPeopleno(),faceRecognitionRecord.getExceptionMode(),
                faceRecognitionRecord.getOutintype(),faceRecognitionRecord.getAddtime());


    }

//    @Override
//    public void addData(JSONObject params) {
//        Gson gson = new Gson();
//        String json = gson.toJson(params.get("data"));
//        TFaceRecognitionRecord faceRecognitionRecord = gson.fromJson(json,TFaceRecognitionRecord.class);
//        faceRecognitionRecordDao.insertData(faceRecognitionRecord);
//    }
}
